<?php /* Smarty version Smarty-3.1.18, created on 2017-09-25 16:40:52
         compiled from "/data/www/mystery/protected/views/report/add.tpl" */ ?>
<?php /*%%SmartyHeaderCode:1444178265553defcc309ba6-32049899%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '3163bb22754c652a68f3085032cebadaafc55897' => 
    array (
      0 => '/data/www/mystery/protected/views/report/add.tpl',
      1 => 1494904493,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '1444178265553defcc309ba6-32049899',
  'function' => 
  array (
  ),
  'version' => 'Smarty-3.1.18',
  'unifunc' => 'content_553defcc33fb09_84730995',
  'variables' => 
  array (
    'project_list' => 0,
    'val' => 0,
    'info' => 0,
    'attach' => 0,
    'network_id' => 0,
    'nr_id' => 0,
  ),
  'has_nocache_code' => false,
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_553defcc33fb09_84730995')) {function content_553defcc33fb09_84730995($_smarty_tpl) {?><?php if (!is_callable('smarty_modifier_date_format')) include '/data/www/mystery/protected/extensions/Smarty/plugins/modifier.date_format.php';
?><?php echo $_smarty_tpl->getSubTemplate ('../common/head.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>

<link href="/css/uploadify.css" rel="stylesheet">
<script src="/js/jquery.uploadify.min.js"></script>
<script type="text/javascript" src='/js/datepicker/WdatePicker.js'></script>
<div class="main w1060">
	<div class="twomain">
		<div class="biaoge">  
                    <h2 class="btzong2">添加报备 Network Records</h2>
                    <form name='myForm1' id='myForm1' method='post' action='/report/Doadd' autocomplete='off'>
			<table width="100%" border="0" cellspacing="0">
                            <tr>
                                <td>选择项目</td>
                                <td>
                                    <select name="project_id" autocomplete="off">
                                    <?php  $_smarty_tpl->tpl_vars['val'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['val']->_loop = false;
 $_smarty_tpl->tpl_vars['key'] = new Smarty_Variable;
 $_from = $_smarty_tpl->tpl_vars['project_list']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['val']->key => $_smarty_tpl->tpl_vars['val']->value) {
$_smarty_tpl->tpl_vars['val']->_loop = true;
 $_smarty_tpl->tpl_vars['key']->value = $_smarty_tpl->tpl_vars['val']->key;
?>
                                    <option value="<?php echo $_smarty_tpl->tpl_vars['val']->value['project_id'];?>
" <?php if ($_smarty_tpl->tpl_vars['info']->value['project_id']==$_smarty_tpl->tpl_vars['val']->value['project_id']) {?>selected="selected"<?php }?>><?php echo $_smarty_tpl->tpl_vars['val']->value['project_name'];?>
</option>
                                    <?php } ?>
                                    </select>
                                </td>
                            </tr>
			  <tr>
				<td>开始时间：</td>
                                <td><input type="text" name="start_time" value="<?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['info']->value['start_time'],"%Y-%m-%d");?>
" id="d4311"  onClick="WdatePicker({minDate:'%y-%M-%d',maxDate:'#F{$dp.$D(\'d4312\')}'})" /></td>
			  </tr>
                          <tr>
				<td>结束时间：</td>
                                <td><input type="text" name="end_time" value="<?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['info']->value['end_time'],"%Y-%m-%d");?>
" id="d4312" onClick="WdatePicker({minDate:'#F{$dp.$D(\'d4311\')}'})" /></td>
			  </tr>
                          <tr>
				<td>报备内容：</td>
                                <td><textarea name="content" cols="60" rows="8" ><?php echo $_smarty_tpl->tpl_vars['info']->value['content'];?>
</textarea></td>
			  </tr>
                          <tr>
				<td>附件：</td>
                                <td>
                                    <input type='file' id="uploadify">(上传按CTRL键可以选择多个操作)
                                    <input type="hidden" id="nra_id" name="nra_id" value="" />
                                    <ul id="attach_list">
                                    <?php if ($_smarty_tpl->tpl_vars['attach']->value) {?>
                                        <?php  $_smarty_tpl->tpl_vars['val'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['val']->_loop = false;
 $_smarty_tpl->tpl_vars['key'] = new Smarty_Variable;
 $_from = $_smarty_tpl->tpl_vars['attach']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['val']->key => $_smarty_tpl->tpl_vars['val']->value) {
$_smarty_tpl->tpl_vars['val']->_loop = true;
 $_smarty_tpl->tpl_vars['key']->value = $_smarty_tpl->tpl_vars['val']->key;
?>
                                        <li id="attach_<?php echo $_smarty_tpl->tpl_vars['val']->value['nra_id'];?>
"><a href="<?php echo $_smarty_tpl->tpl_vars['val']->value['url'];?>
" target="_blank"><?php echo $_smarty_tpl->tpl_vars['val']->value['file_name'];?>
</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="del(<?php echo $_smarty_tpl->tpl_vars['val']->value['nra_id'];?>
);">删除</a></li>
                                        <?php } ?>
                                    <?php }?>
                                    </ul>
                                </td>
			  </tr>
                          <tr><td colspan="2"><input type="submit" id="submit" value="提交" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                  <input type="hidden" name="network_id" value="<?php echo $_smarty_tpl->tpl_vars['network_id']->value;?>
"/>
                                  <input type="hidden" name="nr_id" value="<?php echo $_smarty_tpl->tpl_vars['nr_id']->value;?>
" />
                              </td></tr>
		  </table>
                    </form>
		</div>
	</div>
</div>
<script>
    var nra_id = new Array();
        $(document).ready(function() {     
                var options = {         
                    beforeSubmit:  showRequest,  
                    success:       showResponse,
                    dataType:  'json'
                }
                $('#myForm1').ajaxForm(options); 
                
                
                $('#uploadify').uploadify({
                    'formData'      : {'network_id':<?php echo $_smarty_tpl->tpl_vars['network_id']->value;?>
},
                    'buttonText' : '选择文件',
                    'fileObjName' : 'upfile',   
                    'swf'      : '/js/uploadify.swf',
                    'fileTypeExts' : '*.*',
                    'uploader' : '/attachment/Baobei?attach_type=other',
                    'onUploadSuccess' : function(file, data, response) {
                        var obj = eval('(' + data + ')');
                        if (obj.state =='SUCCESS'){
                            alert('上传成功');
                            nra_id.push(obj.id);
                            $('#nra_id').val(nra_id.join(','));
                            $('#attach_list').append('<li id="attach_'+obj.id+'"><a href="'+obj.url+'" target="_blank">'+obj.file_name+'</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="del('+obj.id+');">删除</a></li>');
                        } else {
                            alert(obj.state);
                        }
                    } 
                });   
        });
            function showRequest(formData, jqForm, options) { 
                return true;
            }
            function showResponse(responseText, statusText, xhr, $form)  { 
                 
                if (responseText.status==1) {
                    $.layer({
                           shade: [0],
                           area: ['auto','auto'],
                           dialog: {
                               msg: '请选择操作？',
                               btns: 2,                    
                               type: 4,
                               btn: ['返回列表','继续添加'],
                               yes: function(){
                                    window.history.go(-1);
                               }, no: function(){
                                   window.location.reload();
                               }
                           }
                       });
                   
                } else {
                    alert(responseText.note); 
                }
            }
            //删除附件
            function del(nra_id){
                $.getJSON('/report/DelAttach',{nra_id:nra_id},function(res){
                    if (res.status == 1) {
                        $('#attach_'+nra_id).remove();
                    }
                    alert(res.note);
                });
            }
    </script>
<!--main End-->
<?php echo $_smarty_tpl->getSubTemplate ("../common/footer.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>
<?php }} ?>
